package ru.ifmo.entities;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;

/**
 * User: Andrew
 * Date: 27-Jun-2010
 * Time: 14:46:55
 */
@javax.persistence.Table(name = "CITIES", schema = "NAMIR")
@Entity
@NamedQuery(name = "city.findById", query = "select title from CitiesEntity where cityId = :id")
public class CitiesEntity {
    private int cityId;

    @javax.persistence.Column(name = "CITY_ID")
    @Id
    public int getCityId() {
        return cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    private int regionId;

    @javax.persistence.Column(name = "REGION_ID")
    @Basic
    public int getRegionId() {
        return regionId;
    }

    public void setRegionId(int regionId) {
        this.regionId = regionId;
    }

    private int countryId;

    @javax.persistence.Column(name = "COUNTRY_ID")
    @Basic
    public int getCountryId() {
        return countryId;
    }

    public void setCountryId(int countryId) {
        this.countryId = countryId;
    }

    private String title;

    @javax.persistence.Column(name = "TITLE")
    @Basic
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CitiesEntity that = (CitiesEntity) o;

        if (cityId != that.cityId) return false;
        if (countryId != that.countryId) return false;
        if (regionId != that.regionId) return false;
        if (title != null ? !title.equals(that.title) : that.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = cityId;
        result = 31 * result + regionId;
        result = 31 * result + countryId;
        result = 31 * result + (title != null ? title.hashCode() : 0);
        return result;
    }
}
